package blueBridge;

import java.util.Scanner;

/*

dp[i][j]的含义为：想买0~j个包子从第1~i种蒸笼中能凑出来的情况数
问题来了，从多少个包子开始能够断定后面更大的包子数都能够凑出来了
还有，怎么判断能否凑出来
我的思路：往前枚举
4 7 8 11 12 14 15 16 19 20 21 22 23 24 25 26 27 28
比如28往前枚举27+1，没有1，凑不出来，26+2，没有2，凑不出来...24+4可以凑出来   

                        *           *   *           *   *       *   *   *           *   *
        0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20
0       0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
1(4)    0   0   0   0   1   1   1   1   2   2   2   2   3   3   3   3   4   5   5   5   6
2(7)    0   0   0   0   1   1   1   2   3   3   3   4   5   5   6   7   8   8   8   9   10


orz换一题吧orzorzorzorz



 */

public class Main98 {
    int n;
    int[] capacity;
    
    
    private Main98(int n, int[] capacity) {
        super();
        this.n = n;
        this.capacity = capacity;
    }
    
    private int unableSum() {
        int ableSum = 0;
        boolean[] able = new boolean[10000];
        int j = 1;
        boolean initOver = false;
        for (int i = 1; i < 10000; i++) {
            if (!initOver && i == capacity[j++]) {
                if (j == n) {
                    initOver = true;
                }
                if (!able[i]) {
                    able[i] = true;
                    ableSum--;
                }
            }
            for (int k = i; k >= 0; i--) {
                if (able[k]) {
                    
                }
            }
        }
        return 0;
    }




    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] capacity = new int[n+1];
        for (int i = 1; i <= n; i++) {
            capacity[i] = scan.nextInt();
        }
        Main98 main = new Main98(n, capacity);
        System.out.println(main.unableSum());
    }





    
}
